How to Set Filter State of Remote Module?

Many DXL calls operate on the current module by default. Often there is an optional parameter to specify another module to operate on. For example:

load(remoteModule, view("Some Existing View"));

Some DXL calls do not have a "module" parameter (in the documentation anyway). Where this is the case, would the code fragment below accomplish the same thing?

//*** BEGIN FRAGMENT ***
void setFilteringStateForRemoteModule(Module thisModule,
Module remoteModule,
bool wantFilteringOn) {
if (thisModule == null) return;
if (remoteModule == null) return;
current = remoteModule; // temporary change
if (wantFilteringOn) {
set filtering on;
} else {
set filtering off;
}
refresh current;
current = thisModule; // Change back
}

// Calls
Module remoteModule = edit("Some Other Module");
load(remoteModule, view("Some Existing View"));
setFilteringStateForRemoteModule(current, remoteModule, true);
//*** END FRAGMENT ***
SystemAdmin - Fri Feb 19 11:19:46 EST 2010

Re: How to Set Filter State of Remote Module?
SystemAdmin - Fri Feb 19 13:50:32 EST 2010

Minor correction -- should be "filtering on" not "set filtering on" -- corrected below

void setFilteringStateForRemoteModule(Module thisModule,
                                      Module remoteModule,
                                      bool wantFilteringOn) {
  if (thisModule == null) return;
  if (remoteModule == null) return;
  current = remoteModule;
  if (wantFilteringOn) {
      filtering on;
  } else {
      filtering off;
  }
  refresh current;
  current = thisModule;
}
 
// Calls
Module remoteModule = edit("Some Other Module");
load(remoteModule, view("Some Existing View"));
setFilteringStateForRemoteModule(current, remoteModule, true);
 
//*** END FRAGMENT ***

Re: How to Set Filter State of Remote Module?
llandale - Tue Feb 23 13:03:43 EST 2010

Should work. But you can get the 'current' module and don't need it as a parameter

void setFilteringStateForRemoteModule(Module remoteModule,
                                      bool wantFilteringOn) {
  if (remoteModule == null) return;
  Module mCurr = current()
  current = remoteModule;
  filtering wantFilteringOn
  refresh remoteModule
  if (!null mCurr) current = mCurr // current = xx will fail on a null module
}
 
// Calls
Module remoteModule = read("Some Other Module", true, true);
load(remoteModule, view("Some Existing View"));
setFilteringStateForRemoteModule(remoteModule, true);
 
//*** END FRAGMENT ***


Thus, the following should be routine when using ANY of those functions that presume the current module, even if you think its already 'current'. The Current module may change as you open other modules, such as those at the other end of a link.

 

Module mCurr = current
current = mod
... deal with 'mod' as the 'current' module
if (!null mCurr) current = mCurr


That assumes that you indeed have a 'handle' on the current module. That usually means the top of your DXL has this:

 

 

Module g_mOriginal = current()
a: if ( null g_mOriginal) ack and halt;        Run this DXL from an open module
b: if (!null g_mOriginal) ack and halt; do NOT run this DXL from an open module
Now you won't forget which module was originally open in which the DXL ran.

 

 

 

  • Louie